<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>江西省财审管理系统</title>
<link rel="stylesheet" type="text/css" href="css/verifyCode.css" />
<script type="text/javascript" src="./easyui/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="./js/util/jquery.cookie.js"></script>
<script type="text/javascript" src="./js/YMLib.js"></script>
<script type="text/javascript" src="./js/index.js"></script>
</head>
<body style="margin:0 0 0 0; min-width: 1000px;overflow-x:hidden; ">
<!-- <script type="text/javascript" src="js/wpFlashWrite.js"></script>
 --><script type="text/javascript">



$(function(){
    if(getUrlParame("un")!=null&&getUrlParame("pw")!=null){
        urllogin();
    }else{
        //alert("3");
        //selQxByUser();
        selSes();
    }

});

function urllogin() {
    $.ajax({
        type: "POST",
        url: "xtgl/urllogin.do",
        dataType: 'json',
        async: false,
        data: "master.truename=" + getUrlParame("un") + "&master.password=" + getUrlParame("pw"),
        success: function (msg) {
            if (msg) {
                $.cookie("truename", msg.TRUENAME, {expires: 1});//将用户名放入cookie中
                if (msg.NAME != null)
                    $.cookie("name", msg.NAME, {expires: 1});//将用户名放入cookie中
                else
                    $.cookie("name", "", {expires: 1});//将用户名放入cookie中
                $.cookie("unit", msg.UNIT, {expires: 1});
                var unit2 = msg.UNIT;
                if (unit2.substr(unit2.length - 2, unit2.length) == "00") unit2 = unit2.substr(0, unit2.length - 2);
                if (unit2.substr(unit2.length - 2, unit2.length) == "00") unit2 = unit2.substr(0, unit2.length - 2);
                if (msg.UNIT == "36") $.cookie("unit2", "_____36", {expires: 1});
                else $.cookie("unit2", unit2, {expires: 1});

                if (msg.UNIT == "36") $.cookie("dist", "360000", {expires: 1});
                else $.cookie("dist", msg.UNIT.substr(msg.UNIT.length - 6, msg.UNIT.length), {expires: 1});

                var dist2 = msg.UNIT.substr(msg.UNIT.length - 6, msg.UNIT.length);
                if (dist2.substr(dist2.length - 2, dist2.length) == "00") dist2 = dist2.substr(0, dist2.length - 2);
                if (dist2.substr(dist2.length - 2, dist2.length) == "00") dist2 = dist2.substr(0, dist2.length - 2);
                $.cookie("dist2", dist2, {expires: 1});
                $.cookie("zgx", msg.ZGX, {expires: 1});
                $.cookie("roleid", msg.ROLEID, {expires: 1});
                selQxByUser1(msg.ROLEID);
                getFwparam("1");
                document.location.href = "./jhgl_index.jsp";
            } else {
                alert("用户名或密码不正确！！");
                clearSession();
            }
        },
        error: function () {
            YMLib.Tools.Show('服务器请求无响应！error code = 404', 3000);
        }
    });
}
//点击登录按钮时
function login(){
	checkText();//检查文本框是否输入
	var base64 = new Base64();
	var length=password.length;
	if(length==10){length="A";}
	else if(length==11){length="B";}
	else if(length==12){length="C";}
	else if(length==13){length="D";}
	else if(length==14){length="E";}
	else if(length==15){length="F";}
	else if(length==16){length="G";}

	password =length+password+randomNum(10000000,99999999);
	password =base64.encode(password);
	if(bl){
		$.ajax({
			type : "POST",
			url : "xtgl/login.do",
			dataType : 'json',
			data :"master.truename="+name+"&master.password="+password+"&master.code="+code,
			success : function(msg){
				if(msg){
		     		if(msg.NAME!=null)
		     		$.cookie("name",msg.NAME, {expires: 1});//将用户名放入cookie中
		     		else
		     			$.cookie("name","", {expires: 1});//将用户名放入cookie中
					$.cookie("truename",msg.TRUENAME, {expires: 1});//将用户名放入cookie中

		     		$.cookie("unit",msg.UNIT, {expires: 1});
		     		var unit2=msg.UNIT;
		     		if(unit2.substr(unit2.length-2,unit2.length)=="00") unit2=unit2.substr(0,unit2.length-2);
		     		if(unit2.substr(unit2.length-2,unit2.length)=="00") unit2=unit2.substr(0,unit2.length-2);
		     		if(msg.UNIT=="36") $.cookie("unit2","_____36", {expires: 1});
		     			else $.cookie("unit2",unit2, {expires: 1});

		     		if(msg.UNIT=="36") $.cookie("dist","360000", {expires: 1});
		     		else $.cookie("dist",msg.UNIT.substr(msg.UNIT.length-6,msg.UNIT.length), {expires: 1});

		     		var dist2=msg.UNIT.substr(msg.UNIT.length-6,msg.UNIT.length);
		     		if(dist2.substr(dist2.length-2,dist2.length)=="00") dist2=dist2.substr(0,dist2.length-2);
		     		if(dist2.substr(dist2.length-2,dist2.length)=="00") dist2=dist2.substr(0,dist2.length-2);
		     		$.cookie("dist2",dist2, {expires: 1});
		     		$.cookie("zgx",msg.ZGX, {expires: 1});

		     		$.cookie("roleid",msg.ROLEID, {expires: 1});
		     		selQxByUser1(msg.ROLEID);
		     		$.cookie("cgdl","true", {expires: 1});


		     		//$('#index_layout').css('visibility', 'visible');
		     	 }
		     	 else{
		     		alert("用户名、密码或验证码不正确！！");
		     		$.ajax({
		     			 type : "POST",
		     			 url : "xtgl/getCode.do",
		     			 dataType : 'json',
		     			 ansync:false,
		     		     success : function(msg){
		     		    	 show_num=msg.toString().split("");
		     		    	 draw(show_num);
		     			}
		     		});

		     	 }
			 },
			 error : function(){
				 YMLib.Tools.Show('服务器请求无响应！error code = 404',3000);
			 }
		});
	}

}

</script>



</body>
</html>
